app.controller('linetake', function ($scope, $http) {
    //页面控制


    //隐藏显示控制
    $scope.hide = 0;//默认隐藏
    $scope.showLine = function (index) {

        if ($scope.hide != index) {
            $scope.hide = index;
        } else {
            if ($('#showOrHide').css('display') == 'block') {
                $scope.hide = -1;
            } else if ($('#showOrHide').css('display') == 'none') {
                $scope.hide = -1;
            }

        }
    };
    //隐藏显示控制
    $scope.hide1 = 0;//默认隐藏
    $scope.showLineDetail = function (index) {

        if ($scope.hide1 != index) {
            $scope.hide1 = index;
        } else {
            if ($('#showOrHide').css('display') == 'block') {
                $scope.hide1 = -1;
            } else if ($('#showOrHide').css('display') == 'none') {
                $scope.hide1 = -1;
            }

        }
    };

    var token = localStorage.getItem('token');
    var classId = sessionStorage.getItem('classId');
    ////id列表
    //$scope.ids=[];
    //路线信息
    $scope.lineInfos = [];
    //路线详情
    $scope.lineInfos.details = [];
    $scope.lineDetail = [];


    $scope.getLine = function () {
        var infiniteScrollPreloader = $('.infinite-scroll-preloader');
        $http({
            method: 'get',
            url: app.netPath + '/line/allinfo',
            headers: {Authorization: token},
            params: {classId: classId}
        }).then(function (res) {
            // 删除加载提示符
            infiniteScrollPreloader.hide();
            console.log(res.data);
            if (!res.data.error) {
                $scope.lineInfos = res.data.data;
                //存放图片
                for (var i = 0; i < $scope.lineInfos.length; i++) {
                    if ($scope.lineInfos[i].detail) {
                        for (var j = 0; j < $scope.lineInfos[i].detail.length; j++) {
                            if ($scope.lineInfos[i].detail[j].lineScenicImg) {
                                $scope.lineInfos[i].detail[j].lineScenicImg = app.netPath + '/resources/lineImg/' + $scope.lineInfos[i].detail[j].lineScenicImg;
                            }
                        }

                    }
                }
                console.log($scope.lineInfos);
            }
            else {
                $.toast('请先购买！');

            }
        }, function () {
            $.toast('网络走丢了！')
        });
    };

});